<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Books</title>
</head>
<body onload="search()">
	<div id="results">
	</div>
	
	<script type="text/javascript">
	function search(){
		$(document).ready(function() {
			$.ajax({
				type : "post",
				url : "../getBookComments.action",
				dataType : "json",
				success : function(data,textStatus) {
					var jsonarray = data.comments;
					var table = document.getElementById('results');
					
					var tab="<table border='1' bordercolor='blue' width='200' height='10'>";
					
					
					//循环行
					for(var i=1;i<=jsonarray.length;i++)
			        {
						if(i==1){
							tab+="<tr>";
							tab+="<td>"+书籍ID+"</td>";
				       		tab+="<td>"+书籍封面+"</td>";
				       	 	tab+="<td>"+书名+"</td>";
				       		tab+="<td>"+作者+"</td>";
				       		tab+="<td>"+简介+"</td>";
				       	 	tab+="<td>"+评星+"</td>";
				       		tab+="<td>"+类型+"</td>";
				       		tab+="<td>"+评论+"</td>";
				            tab+="</tr>";
						}else{
			            	tab+="<tr>";
			            	//循环列
			            	tab+="<td>"+jsonarray[i].bookid+"</td>";
			       			tab+="<td>"+jsonarray[i].cover+"</td>";
			       	 		tab+="<td>"+jsonarray[i].name+"</td>";
			       			tab+="<td>"+jsonarray[i].author+"</td>";
			       			tab+="<td>"+jsonarray[i].description+"</td>";
			       	 		tab+="<td>"+jsonarray[i].star+"</td>";
			       			tab+="<td>"+jsonarray[i].type+"</td>";
			       			tab+="<td>"+jsonarray[i].comments+"</td>";
			            	tab+="</tr>";
						}
			        }
					
					tab+="</table>";
			       	table.innerHTML=tab;

				}
			});
		});
	}
	</script>

	
</body>

</html>